import { RouteRecordRaw } from "vue-router";
import { PageEnum } from "../enums/page";
import { BasicLayout, BlankLayout } from "/@/layout";

import Login from "/@/views/login/index.vue";
import { AppRedirect } from "@scpun/components";
import { REDIRECT_NAME } from "@scpun/router";

/** 全局404页面 */
const NOT_FOUND_ROUTE: RouteRecordRaw = {
    component: () => import("/@/views/_core/exception/404.vue"),
    meta: {
        hideInBreadcrumb: true,
        hideInMenu: true,
        hideInTab: true,
        title: "404",
    },
    name: "NOT_FOUND_ROUTE",
    path: "/:path(.*)*",
};

const coreRoutes: RouteRecordRaw[] = [
    {
        meta: {
            title: "Root",
        },
        name: "Root",
        path: "/",
        redirect: PageEnum.HOME_PATH,
    },
    {
        component: BlankLayout,
        meta: {
            hideInTab: true,
            title: "Authentication",
        },
        name: "Authentication",
        path: "/auth",
        redirect: PageEnum.LOGIN_PATH,
        children: [
            {
                component: Login,
                meta: {
                    hideInMenu: true,
                    title: "Login",
                },
                name: "Login",
                path: "/auth/login",
            },
        ],
    },
];

const REDIRECT_ROUTE: RouteRecordRaw = {
    path: "/redirect",
    component: BasicLayout,
    name: "RedirectTo",
    meta: {
        title: REDIRECT_NAME,
        hideBreadcrumb: true,
        hideMenu: true,
    },
    children: [
        {
            path: "/redirect/:path(.*)",
            name: REDIRECT_NAME,
            component: AppRedirect,
            meta: {
                title: REDIRECT_NAME,
                hideBreadcrumb: true,
            },
        },
    ],
};

export { coreRoutes, NOT_FOUND_ROUTE, REDIRECT_ROUTE };
